package com.tinem.platform.web.tool.controller;

import com.tinem.platform.module.pojo.enums.message.ResourceType;
import com.tinem.platform.module.pojo.enums.web.LinkType;
import com.tinem.platform.module.pojo.vo.link.AddReq;
import com.tinem.platform.module.pojo.vo.link.AddRes;
import com.tinem.platform.module.pojo.vo.link.EventReq;
import com.tinem.platform.module.pojo.vo.link.EventRes;
import com.tinem.platform.module.starter.sdk.api.LinkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

/**
 * @author fengzhihao
 * @version v1
 * @program: platform
 * @className LinkController
 * @description TODO
 * @site
 * @company
 * @create 2022/1/16 21:57:21
 */
@Slf4j
@Controller
@RequestMapping("link")
public class LinkController {

    @Resource
    LinkService linkService;

    @GetMapping("/generate.do")
    @ResponseBody
    public Object open(@RequestParam("url") String url,@RequestParam(value = "resourceId",required = false,defaultValue = "") String resourceId) throws IOException {
        AddReq req = new AddReq();
        req.setUrl(url);
        req.setLinkType(LinkType.URL);
        req.setResourceType(ResourceType.NONE);
        req.setResourceId(resourceId);
        return linkService.add(req);
    }
}
